<?php
//framework/index.php
require_once __DIR__ . '/vendor/autoload.php';

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

$request = Request::createFromGlobals();

// retrieve GET and POST variables respectively
// 分别取出GET和POST变量
$request->query->get('foo');
$request->request->get('bar', 'default value if bar does not exist');

// retrieve SERVER variables
// 取出SERVER变量
$input = $request->server->get('HTTP_HOST');// 必须大写

// 通过foo取出一个UploadedFile实例
$request->files->get('foo');

// 取出一个COOKIE值
$request->cookies->get('PHPSESSID');

// 取出一个HTTP请求头
$request->headers->get('host');
$request->headers->get('content_type');

$request->getMethod(); // GET,POST,PUT
// 客户端所能接收的语言之数组
$request->getLanguages();

//模拟请求
$request = Request::create('/index.php?name=Fabien');
// 获取post或get参数
$input = $request->get('name', 'World');

$response = new Response(sprintf('Hello %s', htmlspecialchars($input, ENT_QUOTES, 'UTF-8')));

// 使用Response,可以轻松调整响应
$response = new Response();
$num = 5;
$location = 'tree';
$format = "The %2$s contains %1$4d monkeys";
echo sprintf($format, $num, $location);
